home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / gurumode / guru-asm.asm < prev    next >
Assembly Source File  |  1993-01-16  |  5KB  |  145 lines

  1. ;----------------------------------------------------------------------------
  2. ;GuruMode    -    12 new 256 color modes for the IBM VGA and
  3. ;            compatibles.  (all modes are "tweaked" modes, e.g.
  4. ;            four bitplanes are used, with a complete pixel in
  5. ;            each plane.)
  6. ;
  7. ;Input(BX)    0    320x175            6    360x175
  8. ;        1    320x200            7    360x200
  9. ;        2    320x240            8    360x240
  10. ;        3    320x350            9    360x350
  11. ;        4    320x400            a    360x400
  12. ;        5    320x480            b    360x480
  13. ;
  14. ;Alters        -    AX,BX,CX,DX,SI,DI,ES, various flags and several
  15. ;            VGA registers.
  16. ;
  17. ;Terms of use    -    Use and distribute freely as long as source remains
  18. ;            100% unchanged.  Donations of 10$, or any amount
  19. ;            are received with gratitude (I'm a student with
  20. ;            a rather tigth budget).
  21. ;                      (C) 8-02-1992 Per Ole Klemetsrud
  22. ;                       Hertug Skulesgt. 15c
  23. ;                       0652 Oslo, Norway
  24. ;
  25. ;Clarke's Third Law:     "Any sufficiently advanced technology is 
  26. ;             indistinguishable from magic."
  27. ;----------------------------------------------------------------------------
  28. model    small
  29.     .code
  30. GuruMode    proc     near
  31.     mov    ax,0013h
  32.     int    10h        ;Start with BIOS mode 13h
  33.  
  34.     mov    dx,03c4h    ;Sequencer Register
  35.     mov    cl,[clocktab+bx]
  36.     cmp    cl,00h        ;Check if reset is necessary
  37.     je    Skip_Reset
  38.  
  39.     mov    ax,0100h    ;Index 0, (Reset Register)
  40.     out    dx,ax        ;Set the system in reset conditon
  41.  
  42.     mov    dx,3c2h        ;Miscellaneous output register
  43.     mov    al,cl        ;Set new sync polarity and clock frequency
  44.     out    dx,al
  45.  
  46.     mov    dx,3c4h        ;Sequencer register
  47.     mov    ax,0300h    ;Index 0, (Reset Register)
  48.     out    dx,ax        ;Release reset
  49. Skip_Reset:
  50.     mov    ax,0604h    ;Index 4, Disable Chain 4 (Set bit 3 to 0)
  51.     out    dx,ax        ;Part of the "Tweak Settings"
  52.  
  53.     mov    ax,0a000h    ;This is a good time to clear RAM to
  54.     mov    es,ax        ;avoid a flick of trash during mode change
  55.     xor    di,di
  56.     xor    ah,ah        ;ES:DI=Video Ram, AX=0000
  57.     mov    cx,(0ffffh/2)    ;Entire Video Segment in words
  58. rep    stosw
  59.  
  60.     mov    dx,03d4h    ;Start filling CRT controller registers
  61.     mov    si,offset [Regtab]
  62.     mov    cx,3        ;Start with the "tweak mode" settings
  63.     cmp    bl,5        ;and continue with horizontal settings
  64.     jbe    CRT1        ;if necessary.
  65.     mov    cx,10
  66. CRT1:      lodsw
  67.     out    dx,ax
  68.     loop    CRT1        ;Now thru with "Tweak" settings
  69.  
  70.     shl    bx,1        ;Make BX a word index, instead of byte index
  71.     mov    si,[vertab+bx]    ;Get address of table to use
  72.     cmp    si,0
  73.     je    finish        ;Do more changes necessary.
  74.     cmp    si,1        
  75.     je    Set400        ;Mode only requiers normal vertical resolution
  76.  
  77.     mov    cx,8        ;Fill CRT controller registers with
  78. CRT2:    lodsw            ;info about horizontal resolution.
  79.     out    dx,ax
  80.     loop    CRT2
  81. finish:    ret
  82.  
  83. Set400: mov    ax,04009h
  84.     out    dx,ax
  85.     ret
  86. GuruMode    endp
  87.  
  88.     .data
  89. Regtab    label    word
  90.     dw    00e11h        ;Index 11, Turn off write protect
  91.     dw    00014h        ;Index 14, Turn off dword mode
  92.     dw    0e317h        ;Index 17, Turn on byte mode
  93. ;----------------------------------------------------------------------------
  94. ;Data to the set the CRT controller to 360 horizontal pixels.
  95. ;Horizontal retrace and blanking periods are based on mode 10h and 12h.
  96. ;----------------------------------------------------------------------------
  97.     db    00h,06bh    ;Horizontal Total        107
  98.     db    01h,059h    ;Horizontal Display End         89
  99.     db    02h,05ah    ;Start Horizontal Blanking     90
  100.     db    03h,08eh    ;End Horizontal Blanking     
  101.     db    04h,05eh    ;Start Horizontal Retrace     94
  102.     db    05h,08ah    ;End Horizontal Retrace      
  103.     db    13h,02dh    ;Offset register         90
  104.  
  105. ;----------------------------------------------------------------------------
  106. ;Data to the set the CRT controller to 480 scanlines, originaly used 
  107. ;by BIOS mode 12h.  Refer to Programmers guide to the EGA/VGA, by 
  108. ;Richard F. Ferraro for details about display timing.
  109. ;----------------------------------------------------------------------------
  110. vert480    label    word
  111.     db    009h,01000000b    ;Maximum Scan Line          0
  112.     db    007h,00111110b    ;Overflow register
  113.     db    006h,00bh    ;Vertical Total            523
  114.     db    010h,0eah    ;Vertical Retrace Start     490
  115.     db    011h,08ch    ;Vertical Retrace End
  116.     db    015h,0e7h    ;Start Vertical Blanking    487
  117.     db    016h,004h    ;End Vertical Blanking
  118.     db    012h,0dfh    ;Vertical Display End        479
  119.     db    012h,0dfh    ;Safe dummy for neat program flow
  120. ;----------------------------------------------------------------------------
  121. ;Data to the CRT controller to set the display to 350 scanlines,
  122. ;originaly used by BIOS mode 10h.  Refer to Programmers guide to the EGA/VGA,
  123. ;by Richard F. Ferraro for details about display timing.
  124. ;----------------------------------------------------------------------------
  125. vert350    label    word
  126.     db    009h,01000000b    ;Maximum Scan Line          0
  127.     db    007h,00011111b    ;Overflow register
  128.     db    006h,0bfh    ;Vertical Total            447
  129.     db    010h,083h    ;Vertical Retrace Start     387
  130.     db    011h,085h    ;Vertical Retrace End
  131.     db    015h,063h    ;Start Vertical Blanking    355
  132.     db    016h,0bah    ;End Vertical Blanking
  133.     db    012h,05dh    ;Vertical Display End        349
  134.     db    012h,05dh    ;Safe dummy for neat program flow
  135. ;----------------------------------------------------------------------------
  136. ;Sync polarities and horizontal clock frequencies for the different modes
  137. ;----------------------------------------------------------------------------
  138. clocktab    label    byte
  139.     db    0a3h, 000h, 0e3h, 0a3h, 000h, 0e3h
  140.     db    0a7h, 067h, 0e7h, 0a7h, 067h, 0e7h
  141.  
  142. vertab    dw    vert350+2,0000h, vert480+2, vert350, 0001h, vert480
  143.     dw    vert350+2,0000h, vert480+2, vert350, 0001h, vert480
  144.  
  145.